/**
 * 
 */
package com.dlplay.flightinfo.db.business;

import java.util.List;
import java.util.logging.Level;

import javax.persistence.EntityManager;

import com.dlplay.flightinfo.data.Airport;
import com.dlplay.flightinfo.db.QueryOperator;


/**
 * @author y140zhan
 *
 */
public class AirportQuery extends QueryOperator<Airport> {
	
	
	
	public AirportQuery(EntityManager em)
	{
		setEntityManager(em);
		validate();
	}
	
	
	public AirportQuery(EntityManager em, Object id)
	{
		setEntityManager(em);
		validate();
		addRestrictionParameter(" name ", id);
		//Set Id Restriction
		getRestrictions().set(0, QueryOperator.ID_SEARCH_EQ);
		//addRestrictions(QueryOperator.ID_SEARCH_EQ);
	}
	
	
	public AirportQuery(EntityManager em, String ejbql)
	{
		setEntityManager(em);
		validate();
		setEjbql(ejbql);
	}

	/* (non-Javadoc)
	 * @see com.assetKeeper.server.template.QueryOperator#getEntityClassName()
	 */
	@Override
	public String getEntityClassName() {
		// TODO Auto-generated method stub
		String name = Airport.class.getSimpleName();
		return name;
	}
	@Override
	public String getWholeEntityClassName() {
		// TODO Auto-generated method stub
		return "com.dlplay.flightinfo.data.Airport";
	}
	
	public List<Airport> searchAirportWithParams(String paramName, String paramValue)
	{
		clearRestrictions();
		addRestrictionParameter(paramName, paramValue);
		List<Airport> infos = getResultList();
		logger.log(Level.INFO,"searchWithParams: size:" + infos.size());
		return infos;
	}
	
	
	public List<Airport> searchAirportWithParams(List<String> params, Airport info)
	{
		
		return searchWithParams(params, info);
	}
	

}
